package com.ctrip.corp.obt.shard.sql.parser.forbidden;

import java.util.regex.Pattern;

/**
 * 判断字段值是否为脱敏后被替换的值
 *
 * @author xukang zhang
 * @date 2023/8/16 13:51
 */
public class DesensitizationForbiddenMatcher implements UpdateForbiddenMatcher {

    private static final Pattern DESENSITIZATION_PATTERN = Pattern.compile("^DESENSITIZATION##.*##$");

    @Override
    public boolean match(String propertyName, Object propertyValue, Object parameterObject, String columnName) {
        if (!(propertyValue instanceof String)) {
            return false;
        }
        return DESENSITIZATION_PATTERN.matcher((String) propertyValue).matches();
    }


    @Override
    public int order() {
        return -100;
    }
}
